﻿using System.Security.Cryptography;
using System.Text;

namespace HY.Common
{
    public class StringHelper
    {
        /// <summary>
        /// MD5加密
        /// </summary>
        /// <param name="inputString">需要加密的内容</param>
        /// <returns></returns>
        public static string MD5Encrypt(string inputString)
        {
            MD5 md5Hasher = MD5.Create();
            byte[] data = md5Hasher.ComputeHash(Encoding.UTF8.GetBytes(inputString));
            StringBuilder sBuilder = new();
            for (int i = 0; i < data.Length; i++)
            {
                sBuilder.Append(data[i].ToString("x2"));
            }
            return sBuilder.ToString();
        }
    }
}
